home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 551-575 / disk_563 / kpri / src.lzh / subs.c < prev    next >
C/C++ Source or Header  |  1991-11-01  |  2KB  |  103 lines

  1. #include "defs.h"
  2.  
  3. Prototype __regargs void  update_list(PE *);
  4. Prototype __regargs void  del_prienv(PE *);
  5. Prototype           void  cleanup(void);
  6. Prototype __regargs void  FreeRem(LONG *);
  7. Prototype __regargs void *AllocRem(PE *, LONG);
  8.  
  9.  
  10. /***********************  del_prienv()  **************************/
  11. __regargs void
  12. del_prienv(PE *pe)
  13. {
  14.   Remove(pe);
  15.   FreeRem(pe->memory);
  16.  
  17.   do_storage_str(NULL);
  18.   update_list(NULL);
  19. }
  20.  
  21.  
  22. /***********************  update_list()  *****************************/
  23. int stored = 0;
  24.  
  25. __regargs void
  26. update_list(PE *pe)
  27. {
  28.   int *store = &stored;
  29.  
  30.   if (pe != NULL)
  31.   {
  32.     ++*store;
  33.     Enqueue(&List_storage_list, pe);
  34.   }
  35.  
  36.   GT_SetGadgetAttrs(Gad_storage_list, win, NULL,
  37.                     GTLV_Labels, &List_storage_list,
  38.                     TAG_END);
  39.   if (pe == NULL)
  40.   {
  41.     --*store;
  42.  
  43.     if (*store < 9)
  44.       DrawImage(win->RPort, images[*store], 205, 32);  /*  refresh logo  */
  45.  
  46.   }
  47. }
  48.  
  49. /***********************  cleanup(void) ******************************/
  50. void
  51. cleanup(void)
  52. {
  53.   if (autom)                /*  last chance */
  54.   {
  55.     for (SHORT i = 0; i < 2; ++i)
  56.       do_all(i);
  57.   }
  58.   PE *pe;
  59.   pe  = (PE *)List_storage_list.mlh_Head;
  60.   while (pe != (PE *)&List_storage_list.mlh_Tail)
  61.   {
  62.     PE *pet = pe->pe_node.ln_Succ;
  63.     RemHead(&List_storage_list);
  64.     FreeRem(pe->memory);
  65.     pe  = pet;
  66.   }
  67.   close_prt();
  68. }
  69.  
  70. /***********************  FreeRem  ******************************/
  71. __regargs void                                /*  like free() */
  72. FreeRem(LONG *memory)
  73. {
  74.   LONG *ptr;
  75.   while(ptr = memory)
  76.   {
  77.     memory  = (LONG *)ptr[0];
  78.     FreeMem(ptr, ptr[1]);
  79.   }
  80. }
  81.  
  82. /***********************  AllocRem ******************************/
  83. __regargs void *                              /*  like malloc() */
  84. AllocRem(PE *pe, LONG bytes)
  85. {
  86.   LONG *ptr;
  87.   ptr = (LONG *)AllocMem(bytes + 8, MPC);
  88.   if (ptr)
  89.   {
  90.     (LONG *)ptr[0] = pe->memory;
  91.     pe->memory = ptr;
  92.     ptr[1] = bytes + 8;
  93.     ptr += 2;
  94.     return((void *)ptr);
  95.   }
  96.   else
  97.   {
  98.     quit  = TRUE;
  99.     autom = TRUE;
  100.   }
  101. }
  102.  
  103.